/*    */ package com.lmpop.trade.util;
/*    */ 
/*    */ import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
/*    */ import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
/*    */ import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
/*    */ import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/*    */ 
/*    */ public class Cn2Spell
/*    */ {
/*    */   public static String converterToFirstSpell(String chines)
/*    */   {
/* 35 */     String pinyinName = "";
/* 36 */     char[] nameChar = chines.toCharArray();
/* 37 */     HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
/* 38 */     defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
/* 39 */     defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
/* 40 */     for (int i = 0; i < nameChar.length; i++) {
/* 41 */       if (nameChar[i] > '')
/*    */         try {
/* 43 */           pinyinName = pinyinName + net.sourceforge.pinyin4j.PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0].charAt(0);
/*    */         } catch (BadHanyuPinyinOutputFormatCombination e) {
/* 45 */           e.printStackTrace();
/*    */         }
/*    */       else {
/* 48 */         pinyinName = pinyinName + nameChar[i];
/*    */       }
/*    */     }
/* 51 */     return pinyinName;
/*    */   }
/*    */ 
/*    */   public static String converterToSpell(String chines)
/*    */   {
/* 61 */     String pinyinName = "";
/* 62 */     char[] nameChar = chines.toCharArray();
/* 63 */     HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
/* 64 */     defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
/* 65 */     defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
/* 66 */     for (int i = 0; i < nameChar.length; i++) {
/* 67 */       if (nameChar[i] > '')
/*    */         try {
/* 69 */           pinyinName = pinyinName + net.sourceforge.pinyin4j.PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0];
/*    */         } catch (BadHanyuPinyinOutputFormatCombination e) {
/* 71 */           e.printStackTrace();
/*    */         }
/*    */       else {
/* 74 */         pinyinName = pinyinName + nameChar[i];
/*    */       }
/*    */     }
/* 77 */     return pinyinName;
/*    */   }
/*    */ 
/*    */   public static void main(String[] args)
/*    */   {
/*    */   }
/*    */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.lmpop.trade.util.Cn2Spell
 * JD-Core Version:    0.6.0
 */